﻿using UnityEngine;
using Interface;
using System.Collections;

namespace Client
{
    public class ClientStartup : MonoBehaviour
    {
        void Start()
        {
            CreateLogger();

            CreateManager();
            InitManager();

            StartCoroutine(DelayEnterGameLogo());
        }

        private void CreateLogger()
        {
            bool EnableLogDebug = Debug.isDebugBuild;
            bool EnableLogInfo = Debug.isDebugBuild;
            bool EnableUnityLog = Debug.isDebugBuild;
            bool DefaultEnableStack = Debug.isDebugBuild;

#if UNITY_EDITOR
            EnableLogDebug = true;
            EnableLogInfo = true;
            EnableUnityLog = true;
            DefaultEnableStack = true;
#endif

            Log.SetLogger(new UnityLogger(EnableLogDebug, EnableLogInfo, EnableUnityLog, DefaultEnableStack));
        }

        private void CreateManager()
        {
            Global.GameLogicManager = new ClientGameLogicManager();
            Global.UIManager = new UIManager();
            Global.LoadingManager = new LoadingManager();
            Global.AssetManager = new AssetManager();
        }
        private void InitManager()
        {
            Global.GameLogicManager.Init();
            Global.UIManager.Init();
        }

        private IEnumerator DelayEnterGameLogo()
        {
            yield return null;

            Global.GameLogicManager.EnterGameLogin();
        }
    }
}
